import static java.lang.Thread.sleep;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-02-17
 * Time: 19:01
 */
class MyRunable implements Runnable{

    @Override
    public void run() {
        while(true){
            System.out.println("Thread");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo2 {
    public static void main(String[] args) {
        //创建一个任务
       Runnable runnable=new MyRunable();
       Thread t=new Thread(runnable);
       t.start();
        while(true){
            System.out.println("Main");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
